package com.daniel.io.stream;

import java.io.*;

/**
 * 详细说明
 *
 * @author Daniel
 * @version V1.0
 * @date 2020/6/16 18:12
 */
public class TestBufferedStream {
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        FileInputStream fis = null;
        // 过滤流不能独立的创建对象，过滤流都需要依赖于已经创建好的节点流
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            fis = new FileInputStream("E:\\开发软件\\IntelliJIDEA\\ideaIU-2020.1.1.win.zip");
            bis = new BufferedInputStream(fis);
            bos = new BufferedOutputStream(new FileOutputStream("D:\\1.zip"));
            byte[] buffer = new byte[1024];
            int len = 0;
            while ((len = bis.read(buffer)) >= 0) {
                bos.write(buffer, 0, len);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (bos != null) {
                    bos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (bis != null) {
                    bis.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
    }
}
